package com.edu.zql;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by User on 2017/10/11.
 */
public class CC {


    public static void main(String[] args) throws InterruptedException {
        Index index = new Index();


        List tt = new ArrayList();

        for (int i = 0; i < 10; i++) {
            t t = new t(index);
            Thread thread = new Thread(t);
            thread.start();
            tt.add(thread);
        }

        Thread.sleep(5000);

        System.out.println(index.i);

    }

    static class Index {
        volatile int i = 0;
    }

    static class t implements Runnable {
        Index index;

        public t(Index index) {
            this.index = index;
        }


        @Override
        public void run() {
            for (int j = 0; j < 2000; j++) {
                index.i++;
            }
        }
    }





}
